package com.hualian.ticket.service.impl;

import com.hualian.ticket.mapper.UserMapper;
import com.hualian.ticket.pojo.User;
import com.hualian.ticket.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @author 陈静
 * @date 2020/10/21 10:21
 */
@Service("userService")
public class UserServiceImpl implements UserService {
    @Resource
    UserMapper userMapper;

    /**
     *  通过电话号码查找用户
     * @param phone 电话号码
     * @return user对象
     */
    @Override
    public User findByPhone(String phone) {
        User user = new User();
        user.setPhone(phone);
        return userMapper.selectOne(user);
    }

    /**
     *  注册用户
     * @param name 名字
     * @param phone 电话
     * @param regDate 注册时间
     * @return 影响行数
     */
    @Override
    public Integer insertUser(String name, String phone, Date regDate) {
        User user = new User();
        user.setName(name);
        user.setPhone(phone);
        user.setRegDate(regDate);
        return userMapper.insertSelective(user);
    }


}
